/**
 * 
 */
package com.tdkj.action.front.mall.shop;

import javax.annotation.Resource;

import org.hibernate.Query;

import com.tdkj.action.BaseAction;
import com.tdkj.model.shop.BeanGood;
import com.tdkj.model.shop.BeanOrder;
import com.tdkj.model.shop.BeanOrderItem;
import com.tdkj.model.shop.BeanShop;
import com.tdkj.service.shop.IBeanGoodService;
import com.tdkj.service.shop.IBeanShopService;

/**
 * @author yninfo
 */
public class GoodAction extends BaseAction {
	
	private Long id ;
	private BeanGood good ;
	private BeanShop shop ;
	private IBeanGoodService goodService;
	private IBeanShopService shopService;
	
	private Long userId ;
	
	public String execute(){
		
		String hql = "from " + BeanOrderItem.class.getName() + " as bean where bean.good.id='"+id+"' ";
		Query query  = this.createQuery(hql);
		
		this.queryByPage(query, "", 10);
		
		good = goodService.getGoodById(id);
		shop = shopService.getShopById(good.getShop().getId());
		
		userId = good.getUser().getId();
		if(good.getSellType() == 1){
			return "goodAuction";
		}
		return "success";
	}
	
	public String owner(){
		return "owner";
	}
	
	public String guest(){
		return "guest";
	}
	
	public String user(){
		return "guest";
	}

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the good
	 */
	public BeanGood getGood() {
		return good;
	}

	/**
	 * @param good the good to set
	 */
	public void setGood(BeanGood good) {
		this.good = good;
	}

	/**
	 * @param goodService the goodService to set
	 */
	@Resource
	public void setGoodService(IBeanGoodService goodService) {
		this.goodService = goodService;
	}

	/**
	 * @return the shop
	 */
	public BeanShop getShop() {
		return shop;
	}

	/**
	 * @param shop the shop to set
	 */
	public void setShop(BeanShop shop) {
		this.shop = shop;
	}

	/**
	 * @param shopService the shopService to set
	 */
	@Resource
	public void setShopService(IBeanShopService shopService) {
		this.shopService = shopService;
	}
	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}
	
	
	
}
